//
//  UIViewController+MBProgressHUD.m
//  AmountBody
//
//  Created by smm on 17/12/6.
//  Copyright © 2017年 RCMTM. All rights reserved.
//

#import "UIViewController+MBProgressHUD.h"

MBProgressHUD *HUD;
//PublicBlankView *defaultPage;

@implementation UIViewController (MBProgressHUD)

//-(void)showLittleDefaultPage:(CGRect)rect andView:(UIView*)view andPointY:(CGFloat)y
//{
//    defaultPage = [PublicBlankView sharedLittleInstanceWithViewController:view andImage:nil andTitle:@"暂无数据" andButtonName:@"" andCGFloat:rect andPointY:y];
//}
//
//-(void)showLittlePartnerDefaultPage:(CGRect)rect andView:(UIView*)view andPointY:(CGFloat)y
//{
//    defaultPage = [PublicBlankView sharedLittleInstanceWithViewController:view andImage:@"prompt_img2.png" andTitle:@"暂无伙伴数据" andButtonName:@"" andCGFloat:rect  andPointY:y];
//}
//
//-(void)showdefaultPage:(CGRect)rect andView:(UIView*)view
//{
//    defaultPage = [PublicBlankView sharedInstanceWithViewController:view andImage:nil andTitle:@"暂无数据" andButtonName:@"" andCGFloat:rect];
//}
//
//-(void)showPartnerDefaultPage:(CGRect)rect andView:(UIView*)view
//{
//    defaultPage = [PublicBlankView sharedInstanceWithViewController:view andImage:@"prompt_img2.png" andTitle:@"暂无伙伴数据" andButtonName:@"" andCGFloat:rect];
//}
//
//-(void)showTanchuViewPage:(CGRect)rect andView:(UIViewController*)view andType:(TanChuADType)type andData:(NSDictionary*)data
//{
//
//}

-(void)hiddendefaultPage
{
//    [defaultPage removeFromSuperview];
}



-(void)showHUDMessage:(NSString *)message
{
    [self showHUDMessage:message andDelay:1.0];
}

-(void)showHUDMessage:(NSString *)message andDelay:(NSTimeInterval)delay
{
    MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    HUD.mode = MBProgressHUDModeText;
    HUD.labelText = message;
    HUD.margin = 10.f;
    HUD.yOffset = 150.f;
    HUD.opacity = 0.7f;
    HUD.removeFromSuperViewOnHide = YES;
    [HUD hide:YES afterDelay:delay];
}

-(void)showLoading
{
    [self showLoadingWith:@"正在加载..."];
}

-(void)showLoadingWith:(NSString *)message
{
    if (HUD) {
        [HUD removeFromSuperview];
    }
    HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    HUD.delegate = self;
    HUD.opacity = 0.4f;
    HUD.labelText = message;
    [HUD show:YES];
}

-(void)loadSuccess
{
    [self loadSuccessWith:@"加载成功"];
}

-(void)loadSuccessWith:(NSString *)message
{
    if (HUD) {
        [HUD removeFromSuperview];
    }
    HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    HUD.delegate = self;
    HUD.opacity = 0.4f;
    UIImage * image = [[UIImage imageNamed:@"success.png"] imageWithRenderingMode:UIImageRenderingModeAutomatic];
    HUD.customView = [[UIImageView alloc] initWithImage:image];
    HUD.mode = MBProgressHUDModeCustomView;
    HUD.labelText = message;
    [HUD hide:YES afterDelay:1.3];
}

-(void)hiddenLoading
{
    if (HUD!=nil) {
        [HUD hide:YES];
    }
}

@end
